package com.blog.controller;

import com.blog.domain.DTO.AddRoleDto;
import com.blog.domain.DTO.RoleListDto;
import com.blog.domain.DTO.StatusDto;
import com.blog.domain.ResponseResult;
import com.blog.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@RestController
@RequestMapping("system/role")
public class RoleController {

	@Autowired
	private RoleService roleService;

	/**角色分页查询
	 *
	 * @param pageNum
	 * @param pageSize
	 * @param roleListDto
	 * @return
	 */

	@GetMapping("/list")
	public ResponseResult pageRoleselect(Integer pageNum, Integer pageSize,
	                                     RoleListDto roleListDto){

		return roleService.pageRoleselect(pageNum,pageSize,roleListDto);

	}

	/**更改角色状态
	 *
	 * @param statusDto
	 * @return
	 */

	@PutMapping("/changeStatus")
	public ResponseResult updateRoleStatus(@RequestBody StatusDto statusDto){

		return roleService.updateRoleStatus(statusDto);

	}

	/**新增角色
	 *
	 * @param addRoleDto
	 * @return
	 */

	@PostMapping
	public ResponseResult addRole(@RequestBody AddRoleDto addRoleDto){

		return roleService.addRole(addRoleDto);
	}

	/**
	 * 角色基础信息回显
	 *
	 * @param id
	 * @return
	 */

	@GetMapping("/{id}")
	public ResponseResult getRoleDetailById(@PathVariable Long id){
		return roleService.getRoleDetailById(id);

	}

	/**更新角色信息
	 *
	 * @param addRoleDto
	 * @return
	 */

	@PutMapping
	public ResponseResult updateRoleDetail(@RequestBody AddRoleDto addRoleDto){

		return roleService.updateRoleDetail(addRoleDto);

	}

	/**删除角色
	 *
	 * @param ids
	 * @return
	 */
	@DeleteMapping("/{id}")
	public ResponseResult deleteRole(@PathVariable("id")List<Long> ids){

		return roleService.deleteRole(ids);
	}

	/**查询角色列表
	 *
	 * @return
	 */
	@GetMapping("/listAllRole")
	public ResponseResult getRoleList(){

		return roleService.getRoleList();

	}


}
